package com.budwk.app.sqfwV2.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.alibaba.fastjson.JSONObject;
import com.budwk.app.sqfw.vo.GenerateExcelUrlVO;
import com.budwk.app.sqfwDoc.dto.TemplateCodeUpdateDTO;
import com.budwk.app.sqfwV2.dto.entity.AssistanceFormSummaryDraft;
import com.budwk.app.sqfwV2.service.AssistanceSummaryDraftService;
import com.budwk.starter.common.openapi.annotation.ApiDefinition;
import com.budwk.starter.common.openapi.annotation.ApiFormParams;
import com.budwk.starter.common.openapi.annotation.ApiOperation;
import com.budwk.starter.common.openapi.annotation.ApiResponses;
import com.budwk.starter.common.result.Result;
import com.budwk.starter.log.annotation.SLog;
import lombok.extern.slf4j.Slf4j;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.*;

import java.util.List;

@IocBean
@At("/platform/sqfw/assistance/summaryDraft")
@ApiDefinition(tag = "草稿箱功能api")
@Slf4j
public class AssistanceSummaryDraftController {

    @Inject
    private AssistanceSummaryDraftService summaryDraftService;

    @At
    @Ok("json")
    @POST
    @ApiOperation(name = "提交数据")
    @ApiFormParams(implementation = AssistanceFormSummaryDraft.class)
    @SLog(tag = "草稿箱功能新增接口", value = "${args[0]}")
    @SaCheckLogin
    public Result<?> submitData(@Param("..") AssistanceFormSummaryDraft dto) {
        log.info("AssistanceSummaryDraftController submitData param: {}", JSONObject.toJSONString(dto));
        summaryDraftService.submitData(dto);
        return Result.success();
    }

    @At
    @Ok("json")
    @POST
    @ApiOperation(name = "查询当前单位所有的数据")
    @ApiFormParams(implementation = AssistanceFormSummaryDraft.class)
    @SaCheckLogin
    public Result<?> queryAll(@Param("..") AssistanceFormSummaryDraft dto) {
        log.info("AssistanceSummaryDraftController queryAll param: {}", JSONObject.toJSONString(dto));
        return Result.data(summaryDraftService.queryAll(dto));
    }

    @At
    @Ok("json")
    @DELETE
    @ApiOperation(name = "删除草稿箱功能")
    @SaCheckLogin
    public Result<?> deleteData(@Param("draftId") String draftId) {
        log.info("AssistanceSummaryDraftController deleteData param: {}", draftId);
        summaryDraftService.deleteData(draftId);
        return Result.success();
    }


}
